<?php

class p_order extends page_controllor 
{
    public function __construct($get_param)
    {
    	$this->set_page_id('p_product_list');
        parent::__construct($get_param);
    }
    
    public function run()
    {
        $oProduct = K::load_mod('product');
        
        $oBuy = K::load_mod('product_buy');
        $oBuy->list_by_uid(array($this->visitor['uid']) , array(K_COMMON_NO) , 0 , 0) or $this->busy();
        $aOrder = $oBuy->get_data();
        
        if(count($aOrder)>0)
        {
            foreach ($aOrder as $row)
            {
                $aPid[] = $row['pid'];
            }
            
            $oProduct->list_by_id($aPid,array()) or $this->busy();
            $aProduct = $oProduct->get_key2map();
            foreach ($aProduct as $k => $row)
            {
                 $aProduct[$k]['name'] = $this->__isLangEng ? K_str::un_html($row['eng_name']) : K_str::un_html($row['name']);
                 $aProduct[$k]['cover_url'] = product2coverpath($row['id'] , true);
                 $aProduct[$k]['product_url'] = '/product/show/'.$row['sn'];
            }
        
        }
        
        
        
        
    	
        
        $out_data['products'] = $aProduct;
        $out_data['orders'] = $aOrder;

        $this->set_page_title($this->__lang['gTitle_p_productList'].'_'.$this->__lang['gTitle_page_title']);
        $this->output('orderd',$out_data);
    }
}
?>